<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$return['ischecklogin']=model('jy_weishop/member')->checklogin('','','','',true);
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	set_html('title',$this->setting['jie_title']?:'邀请任务');
	$return['pluginset']['goods_opentime']=date('Y-m-d',$return['pluginset']['goods_opentime']);
	$return['isyaonum']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'fromuser'=>$_SESSION['uid']));
	$return['paiordernum']=pdo_count('jy_cunfeepai_order',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$return['paiordernum1']=pdo_count('jy_cunfeepai_order',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>0));
	$return['myurl']=custom_url('jy_cunfeepai/index//fromuser='.$_SESSION['uid'],true);
	$nowplugin=$_SESSION['current_plugin']?:'jy_cunfeepai';
	$menus_index=$_SESSION['menus_index']?:$nowplugin.'/index/';
	$return['indexaction']=$menus_index;
	$return['homeaction']='jy_cunfeepai/index/';
	$sharelink='jy_cunfeepai/index//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
		'title'=>$return['pluginset']['title']?$return['pluginset']['title']:'活动页-免单活动区',
		'desc'=>$return['pluginset']['desc']?$return['pluginset']['desc']:'免单活动区！',
		'lnk'=>custom_url($sharelink,true),
		'imgUrl'=>ATTACHMENT_URL.$return['pluginset']['logo']
	);
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'fromuser'=>$_SESSION['uid']);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('core_members',$params,array($pindex,$psize),$total,array('id','nickname','username','avatar','createtime'),'',$orderby);
	foreach($return['list'] as &$item){
		$item['nickname']=$item['nickname']?:$item['username'];
		$item['nickname'].='(ID:'.$item['id'].')';
		$item['avatar']=tomedia($item['avatar']);
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
	}
	exi($return);
}